<!DOCTYPE html>
	<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0">
		<title>Document</title>
		<link rel="stylesheet" href="../layui/css/layui.css">
		<link rel="stylesheet" type="text/css" href="../css/i-party.css">
	</head>
	<body>
	<form action="">
		<div class="select">
			<div>
				<div class="center select-t">
					<p>发布约会</p>
					<img src="../img/cancel.png" class="close">
				</div>
				<div class="select-b">
					<p>提示：发布约会即扣除10美金</p>
					<div class="flex top-up-box">
						<p>支付金额：<span>￥510</span></p>
						<div class="top-up"><a href="recharge_usd.html">去充值</a></div>
					</div>
					<div class="sure center"><input type="submit" id="submit" name="" value="确定发布"></div>
				</div>
			</div>
		</div>
		<header>
			<a href="javascript:history.back(-1)" class="back"><img src="../img/back.png" height="18px"></a>
			<div class="center title">发布约会</div>
		</header>
		<main>
			<div class="flex">
				<p>性别要求：</p>
			    <div class="female">
				    <input type="radio" id="female" name="ySex" />
				    <label for="female">女</label>
				</div>
				<div class="male">
				    <input type="radio" id="male" name="ySex" />
				    <label for="male">男</label>
				</div>
			</div>
			<div class="flex">
				<p>约会地点：</p>
				<input type="text" name="yAddress">
			</div>
			<div class="flex">
				<p>赴约时间：</p>
				<input type="text" name="yDate">
			</div>
			<div class="flex">
				<p>约会留言：</p>
				<textarea name="yContext"></textarea>
			</div>
		</main>
		<div class="parting-line"></div>
		<div class="money">
			<div class="flex">
				<div class="flex need">
					<p>需要人数:</p>
					<input type="text" name="">
				</div>
				<div class="flex need">
					<p>悬赏金:</p>
					<input type="text" name="yMeijin">
				</div>
				<div class="flex need">
					<p>诚意金:</p>
					<input type="text" name="">
				</div>
			</div>
			<div class="flex pay">
				<p>支付方式：</p>
				<div class="pay-r">
					<span><input type="radio" name=" yPingtai" checked>平台担保</span>
					<span><input type="radio" name=" yPingtai">线下支付</span>
				</div>
			</div>
		</div>
		<div class="parting-line"></div>
		<div class="upload clearfix">
			<p>上传约会地点照片</p>
			<div class="add_photo">+<input type="file" name="mfile" id="file" value=""></div>
		</div>
		<div class="parting-line"></div>
		<div class="fabu center">发布约会</div>

	</form>
		<script src="../js/jquery-3.3.1.js"></script>
		<script src="../layui/layui.all.js"></script>
		<script src="../js/i-party.js"></script>
	</body>
</html>
<script>
	var arr=[];
	$("#file").change(function() {
		//获取图片信息
		var fileLise = $(this)[0].files;
		var fileLength = fileLise.length;
		//然后循环 生成html 插入页面上 最后就赋值给img
		for (var i = 0; i < fileLength; i++) {
			var imgDiv = '<div class="imgDiv" style="width: 80px;height: 80px;display: inline-block;border: none;margin: 15px;"><img style="width: 100%;height: 100%" id="img' + fileLise[i].name + '"></div>';
			$(".upload").append(imgDiv);
			var imgName = document.getElementById("img" + fileLise[i].name);
			// var imgurl=window.URL.createObjectURL(fileLise[i]);
			if (fileLise && fileLise[i]) {
				var file = new FileReader();
				file.readAsDataURL(fileLise[i]);
				file.onload = function() {
					console.log(this);
					imgName.src = this.result;
				}
				arr.push($(this)[i].files[0]);
			}

			if(arr.length>=3){
				$('.add_photo').hide();
			}else {
				$('.add_photo').show();
			}
		}
	});
	$(document).on("click", ".imgDiv", function() {
		var index=$(this).index();
		arr.splice(index-2,1);
		$(this).remove();
		if(arr.length<3){
			$('.add_photo').show();
		}
	});
	$('#submit').click(function () {

		console.log(arr);
		return false;
	});
</script>
